package com.example.contacts;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {
    RecyclerView recyclerView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        recyclerView = findViewById(R.id.recyclerview);
        ArrayList<ContactsModel> contactsList = new ArrayList<>();
        contactsList.add(new ContactsModel("张三"));
        contactsList.add(new ContactsModel("李四"));
        contactsList.add(new ContactsModel("王五"));


        RecyclerViewAdapter recyclerViewAdapter = new RecyclerViewAdapter(MainActivity.this, contactsList);
        recyclerView.setAdapter(recyclerViewAdapter);
        recyclerView.setLayoutManager(new LinearLayoutManager(MainActivity.this));
    }

}